/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Util;

import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle;
import javax.swing.JPanel;

/**
 * Classe simples para um personagem com apenas 1 imagem
 * @author Lucas
 */
public class Sprite implements Drawable{
    Image img;
    int x, y;
    Rectangle r;

    public Sprite(String nome, int x, int y) {
        this.x = x;
        this.y = y;

        img = ImageReader.read("/Imagens/" + nome + ".png");
        r = new Rectangle(x, y, img.getWidth(null), img.getHeight(null));
    }

    public Image getImage() {
        return img;
    }

    public void setPos(int x, int y) {
        this.x = x;
        this.y = y;
        r.x = x;
        r.y = y;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }
    
    @Override
    public void draw(Graphics2D g2d, JPanel j){
        g2d.drawImage(img, x, y, j);
    }
    
    public Rectangle getRect(){
        return r;
    }
}